/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package plash.display;

import plash.utils.ColorMapper;
import processing.core.PGraphics;

/**
 *
 * @author  #0K Srinivasan <hashok.com>
 */
public class GraphicStroke implements IGraphicCommand
{

    private int _thickness;
    private int _rgb;
    private float _alpha;
    protected Graphics __g;
    private PGraphics _painter;
    private ColorMapper _cmapper;

    public GraphicStroke(Graphics g, int lineThickness, int rgb, float alpha)
    {
        __g = g;
        _thickness = lineThickness;
        _painter = g.getPainter();
        _cmapper = new ColorMapper(alpha, rgb);
        _alpha = alpha;
    }

    @Override
    public void execute()
    {
        if (__g == null)
        {
            return;
        }
        if (__g.getOwner().getPainter() == null)
        {
            return;
        }

        if (_cmapper.getAlpha() == 0)
        {
            __g.getOwner().getPainter().noStroke();
            return;
        }
        __g.getOwner().getPainter().strokeWeight(_thickness);
        __g.getOwner().getPainter().stroke(_cmapper.getRed(), _cmapper.getGreen(), _cmapper.getBlue(), _cmapper.getAlpha() * __g.getOwner().getAlpha());
    }
}
/**
 * if (_g.getOwner().isIsMasker())
            {
                _g.getOwner().getMaskPainter().strokeWeight(_thickness);
                _g.getOwner().getMaskPainter().stroke(
                        255,
                        255,
                        255,
                        255);
            }
            else
            {
                _g.getOwner().getMaskPainter().strokeWeight(_thickness);
                _g.getOwner().getMaskPainter().stroke(
                        _cmapper.getRed(),
                        _cmapper.getGreen(),
                        _cmapper.getBlue(),
                        _cmapper.getAlpha() * _g.getOwner().getAlpha());
            }
 */